package com.quanyan.place.service;


import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import com.quanyan.place.entity.*;
import com.quanyan.place.entity.apireq.*;
import org.apache.ibatis.annotations.Param;

import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.orderpay.response.RespPreOrder;
import com.quanyan.place.entity.apiresp.RespPlaceOrderDetails;
import com.quanyan.place.entity.apiresp.RespPlaceOrderMessage;
import com.quanyan.place.entity.apiresp.RespPlaceUtilizationVo;
import com.quanyan.place.entity.vo.DictPlaceDataVo;
import com.quanyan.place.entity.vo.PlaceScanOrderPayVo;
import com.quanyan.place.entity.vo.RespPlaceRevenueStats;

/**
 * 后台管理订单模块
 */
public interface PlaceOrderService {

    /**
     * 分页列表查询 扫描支付订单
     * @param reqPlaceOrderSearchVo
     * @return
     */
    PageObj<List<TbStadiumSellHistory>> queryPlaceScanOrderList(ReqPlaceScanOrderSearchVo reqPlaceOrderSearchVo);

    /**
     * 查询场馆单元
     * @param reqPalceOrderDetailVo
     * @return
     */
    //RespBizPlaceOrderInfo getProuductUnitInfo(ReqPlaceOrderDetailVo reqPalceOrderDetailVo);

    /**
     * 查询条件设定
     * @return
     */
    Map<String,List<DictPlaceDataVo>> getOrderCondition(Integer businessMode);

    /**
     * 营收统计
     * @param reqRevenueVo
     * @return
     */
    List<RespPlaceRevenueStats> getPlaceOrderAmountStats(@Param("reqRevenueVo")ReqRevenueVo reqRevenueVo);
    /**
     * 场地使用率统计 空闲小时数 和 非空闲小时数
     * @param reqRevenueVo
     * @return
     */
    List<RespPlaceUtilizationVo> getPlaceUtilizationStatistics(ReqRevenueVo reqRevenueVo);

    /**
     * 分页列表查询new
     * @param reqPlaceOrderSearchVo
     * @return
     */
    PageObj<List<RespPlaceOrderMessage>> getPlaceOrderMessageList(ReqPlaceOrderSearchVo reqPlaceOrderSearchVo);

    /**
     *  不分页导出new
     * @param reqPlaceOrderSearchVo
     * @return
     */
    List<RespPlaceOrderMessage> getPlaceOrderMessageListExport(ReqPlaceOrderSearchVo reqPlaceOrderSearchVo);

    List<TbBizPlaceOrder> getPlaceOrderList(ReqPlaceOrderSearchVo reqPlaceOrderSearchVo);


    /**
     * 订单详情
     * @param reqPalceOrderDetailVo
     * @return
     */
    RespPlaceOrderDetails placeOrderMessageDetail(ReqPlaceOrderDetailVo reqPalceOrderDetailVo);

    /**
     * 商家端扫码支付
     * @param reqScanPay
     * @throws Exception
     */
    APIResponse<RespPreOrder> placeScanPay(ReqScanPay reqScanPay) throws Exception;

    /** 生成业务订单，扫码支付 **/
    APIResponse<?> scanOrderPay(PlaceScanOrderPayVo placeScanOrderPayVo) throws Exception;
    
    /** 生成业务订单，扫码支付 **/
    APIResponse<?> scanBlockOrderPay(PlaceScanOrderPayVo placeScanOrderPayVo) throws Exception;

    List<TbBizPlaceOrderItem> getTbBizPlaceOrderItem(String placeOrderId);

    TbBizPlaceOrder getOrderListByPlaceOrderId(String placeOrderId);

    /** 判断订单是否是会员订单 **/
    APIResponse<?> isMemberOrderByPlaceOrderId(String placeOrderId);

    /**
     * 商家端后端开单
     * @param reqBillingInfo
     * @return
     */
    APIResponse<?> saveBilling(ReqBillingInfo reqBillingInfo) throws Exception;

    /**
     * 开单(扫码支付)
     * @param reqBillingInfo
     * @return
     * @throws Exception
     */
    APIResponse<?> saveBillingForScanPay(ReqBillingInfo reqBillingInfo) throws Exception;

    /**
     * 会员开单
     * @param reqBillingInfo
     * @return
     */
    APIResponse<?> saveBillingForMember(ReqBillingInfo reqBillingInfo) throws Exception;

    /**
     * 会员开单 增强 by yxj
     * @param reqBillingInfo
     * @return
     */
    APIResponse<?> saveBillingForMemberPlus(ReqBillingInfo reqBillingInfo) throws Exception;

    /**
     * 商家端后端会员预订
     * @param reqBillingInfo
     * @return
     */
    boolean saveBookForMember(ReqBillingInfo reqBillingInfo) throws Exception;

    /**
     * 商家端后端会员预订 增强 by yxj
     * @param reqBillingInfo
     * @return
     */
    APIResponse saveBookForMemberPlus(ReqBillingInfo reqBillingInfo) throws Exception;

    /**
     * 商家端后端预订
     * @param reqBillingInfo
     * @return
     */
    boolean saveBook(ReqBillingInfo reqBillingInfo);

    /**
     * 商家端后端预订 增强 by yxj
     * @param reqBillingInfo
     * @return
     */
    APIResponse<?> saveBookPlus(ReqBillingInfo reqBillingInfo) throws Exception;

    /**
     * 商家端后端取消预订
     * @param reqPlaceOrderId
     * @return
     */
    boolean cancelBook(String reqPlaceOrderId) throws Exception;
    
    /**
     * 商家端后端包场子订单取消预订
     * @param reqPlaceOrderId
     * @return
     */
    boolean cancelBlockBook(String reqPlaceOrderId);


    /**
     * 商家端后端预订后支付
     * @param reqPlaceOrderId
     * @return
     */
    APIResponse savePay(String reqPlaceOrderId,Integer adminPayType,String receivedAmount,String memo,String expression) throws Exception;
    
    /**
     * 商家端后端包场预订后支付
     * @param reqPlaceOrderId
     * @return
     */
    APIResponse saveBlockPay(String reqPlaceOrderId,Integer adminPayType,String receivedAmount,String memo,String expression) throws Exception;
    

    List<TbBizPlaceUnitSalePlan> lockTbBizPlaceUnitSalePlanEx(ReqPlaceOrderListVo reqPlaceOrderListVo, Byte status);

    // 更新销售计划
    int updateSalePlanByPrimaryKeyList(ReqPlaceOrderListVo reqPlaceOrderListVo);

    List<TbBizPlaceUnitSalePlan> lockTbBizPlaceUnitSalePlanExPlus(ReqPlaceOrderListVo reqPlaceOrderListVo) throws Exception;

    /**
     * 更新销售计划状态为2   [2:锁定销售计划]
     * @param reqPlaceOrderListVo
     * @return
     * @throws Exception
     */
    int updateSalePlanLockStatus(ReqPlaceOrderListVo reqPlaceOrderListVo) throws Exception;

    /**
     * 更新销售计划状态为3    [3:销售计划已售出]
     * @param reqPlaceOrderListVo
     * @return
     * @throws Exception
     */
    int updateSalePlanOrderStatus(ReqPlaceOrderListVo reqPlaceOrderListVo) throws Exception;

    /**
     * 根据订单明细修改销售计划状态为3  [3:销售计划已售出]
     * @param tbBizPlaceOrderItems
     * @throws Exception
     */
    void placeBillingUpdatePlaceUnitSalePlanPlus(List<TbBizPlaceOrderItem> tbBizPlaceOrderItems) throws Exception;

    /*
   判断销售计划间有没有重叠
    */
    APIResponse salePlansVerification(List<TbBizPlaceUnitSalePlan> tbBizPlaceUnitSalePlanList);

    /**
     * 购物车下单
     * @param reqShoppingCart
     * @return
     */
    //APIResponse multiGoodsOrder(ReqShoppingCart reqShoppingCart);
    
    /**
     * 检查包场子订单，全部付款或者退款，修改父订单状态
     * @param placeOrder
     * @param orderStatus
     */
    void checkBlockOrder(TbBizPlaceOrder placeOrder, Byte orderStatus , BigDecimal receivedAmount);
    
    
    APIResponse shoppingCart(ReqShoppingCart reqShoppingCart) throws Exception;

    /** 商品快速加入购物车校验库存并返回当前库存 **/
    APIResponse<?> checkGoodCartForGoods(ReqPlaceGoodsVo reqPlaceGoodsVoPara);

    /** 购物车预订再支付 **/
    APIResponse<?> shoppingCartBookPay(String reqPlaceOrderId,Integer adminPayType,
                                       String receivedAmount,String memo,
                                       String expression,String scanCode) throws Exception;
    /** 购物车预订再支付 -- 扫码枪**/
    TbBizPlaceOrder getTbBizPlaceOrderByOrderNoForShoppingCart(String placeOrderId,Integer adminPayType,String receivedAmount,String memo,String expression) throws Exception;

    /**
     * 购物车取消预订
     * @param reqPlaceOrderId
     * @return
     */
    APIResponse<?> placeCancelShoppingCard(String reqPlaceOrderId);

    /**
     * 购物车订单退款
     * @param placeOrderId
     * @return
     * @throws Exception
     */
    APIResponse placeRefundShoppingCard(String placeOrderId, Integer operateUid) throws Exception;

    /** 扫码枪退款 **/
    TbBizPlaceOrder placeScanRefund(TbBizPlaceOrder tbBizPlaceOrder,
                                    List<TbBizPlacePayItem> tbBizPlacePayItems,
                                    List<TbBizPlaceOrderItem> tbBizPlaceOrderItems,
                                    String childrenOrderId) throws Exception;

    /** 释放场地库存 **/
    void refundUpdateUnitSalePlan(List<TbBizPlaceOrderItem> tbBizPlaceOrderItems,Byte status) throws Exception;

    /** 校验购物车会员卡是否支持 **/
    APIResponse checkMemberCard(ReqShoppingCart reqShoppingCart);

}